package com.example.medicine.View;


import com.example.medicine.Bean.jingfang;
import com.example.medicine.Mapper.fjglMapper;
import com.example.medicine.Mapper.yonghuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;

@Controller
public class fjglView {
    @Autowired
    private fjglMapper fjglMapper;
    @Autowired
    private yonghuMapper yonghuMapper;
    @RequestMapping("/fjgl")
    public String fjglShow(Model model){
        List<String> yonghuId = yonghuMapper.getUserIdFour();
        List<String> yonghuCompany = yonghuMapper.getCompany();
        model.addAttribute("yonghuId",yonghuId);
        model.addAttribute("yonghuCompany",yonghuCompany);
        return "pages/fjgl/list";
    }
    @RequestMapping("/fjgl/create")
    public String fjglCreateShow(){
        return "pages/fjgl/create";
    }

    @RequestMapping("/fjgl/edit/{id}")
    public String getfjglById(@PathVariable int id, Model model) throws IOException {
        jingfang jingfang=fjglMapper.getById1(id);
        jingfang.setId(id);
        model.addAttribute("jingfang",jingfang);
        return "pages/fjgl/edit";

    }
    @RequestMapping("/fjgl/edit")
    public String getfjgl(){
        return "pages/fjgl/edit";
    }
    @RequestMapping("/fjgl/batchAdd")
    public String batchAddShow(){
        return "pages/fjgl/batchAdd";
    }
}
